home *** CD-ROM | disk | FTP | other *** search
- /*
- File: NumberFormatting.h
-
- Version: Technology: 8.0
- Release: Universal Interfaces 3.0d3 on Copland DR1
-
- Copyright: © 1984-1996 by Apple Computer, Inc. All rights reserved.
-
- Bugs?: If you find a problem with this file, send the file and version
- information (from above) and the problem description to:
-
- Internet: apple.bugs@applelink.apple.com
- AppleLink: APPLE.BUGS
-
- */
- #ifndef __NUMBERFORMATTING__
- #define __NUMBERFORMATTING__
-
- #ifndef __CONDITIONALMACROS__
- #include <ConditionalMacros.h>
- #endif
- #ifndef __TYPES__
- #include <Types.h>
- #endif
- #if FOR_SYSTEM8_PREEMPTIVE
- #ifndef __TEXTOBJECTS__
- #include <TextObjects.h>
- #endif
- #ifndef __TEXTCOMMON__
- #include <TextCommon.h>
- #endif
- #ifndef __LOCALEOBJECTS__
- #include <LocaleObjects.h>
- #endif
- #ifndef __TEXTPARSER__
- #include <TextParser.h>
- #endif
- #endif
- #if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
- #ifndef __INTLRESOURCES__
- #include <IntlResources.h>
- #endif
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import on
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
- /*
-
- Here are the current System 7 routine names and the translations to the older forms.
- Please use the newer forms in all new code and migrate the older names out of existing
- code as maintainance permits.
-
- New Name Old Name(s)
-
- ExtendedToString FormatX2Str
- FormatRecToString Format2Str
- NumToString
- StringToExtended FormatStr2X
- StringToFormatRec Str2Format
- StringToNum
-
- */
- #if FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE
- struct NumFormatString {
- UInt8 fLength;
- UInt8 fVersion;
- char data[254]; /* private data */
- };
- typedef struct NumFormatString NumFormatString;
-
- typedef NumFormatString NumFormatStringRec;
- #endif
- #if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
- typedef short FormatStatus;
-
- enum {
- fVNumber = 0 /* first version of NumFormatString */
- };
-
- typedef SInt8 FormatClass;
-
- enum {
- fPositive = 0,
- fNegative = 1,
- fZero = 2
- };
-
- typedef SInt8 FormatResultType;
-
- enum {
- fFormatOK = 0,
- fBestGuess = 1,
- fOutOfSynch = 2,
- fSpuriousChars = 3,
- fMissingDelimiter = 4,
- fExtraDecimal = 5,
- fMissingLiteral = 6,
- fExtraExp = 7,
- fFormatOverflow = 8,
- fFormStrIsNAN = 9,
- fBadPartsTable = 10,
- fExtraPercent = 11,
- fExtraSeparator = 12,
- fEmptyFormatString = 13
- };
-
- struct FVector {
- short start;
- short length;
- };
- typedef struct FVector FVector;
-
- /* index by [fPositive..fZero] */
- typedef FVector TripleInt[3];
- #if CGLUESUPPORTED
- extern void stringtonum(const char *theString, long *theNum);
-
- extern void numtostring(long theNum, char *theString);
-
- #endif
- /* CGLUESUPPORTED*/
- #endif
- #if FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE
- extern pascal void StringToNum(ConstStr255Param theString, long *theNum);
-
- extern pascal void NumToString(long theNum, Str255 theString);
-
- #endif
- #if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
- extern pascal FormatStatus ExtendedToString(extended80 *x, const NumFormatString *myCanonical, const NumberParts *partsTable, Str255 outString)
- FOURWORDINLINE(0x2F3C, 0x8210, 0xFFE8, 0xA8B5);
-
- extern pascal FormatStatus StringToExtended(ConstStr255Param source, const NumFormatString *myCanonical, const NumberParts *partsTable, extended80 *x)
- FOURWORDINLINE(0x2F3C, 0x8210, 0xFFE6, 0xA8B5);
-
- extern pascal FormatStatus StringToFormatRec(ConstStr255Param inString, const NumberParts *partsTable, NumFormatString *outString)
- FOURWORDINLINE(0x2F3C, 0x820C, 0xFFEC, 0xA8B5);
-
- extern pascal FormatStatus FormatRecToString(const NumFormatString *myCanonical, const NumberParts *partsTable, Str255 outString, TripleInt positions)
- FOURWORDINLINE(0x2F3C, 0x8210, 0xFFEA, 0xA8B5);
-
- #endif
- #if OLDROUTINENAMES
- #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
- #define FormatX2Str(x, myCanonical, partsTable, outString) \
- ExtendedToString( x, myCanonical, partsTable, outString)
- #define FormatStr2X(source, myCanonical, partsTable, x) \
- StringToExtended( source, myCanonical, partsTable, x)
- #define Str2Format(inString, partsTable, outString) \
- StringToFormatRec(inString, partsTable, outString)
- #define Format2Str(myCanonical, partsTable, outString, positions) \
- FormatRecToString(myCanonical, partsTable, outString, positions)
- #endif
- /* FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED*/
- #endif
- /* OLDROUTINENAMES*/
- #if FOR_SYSTEM8_PREEMPTIVE
- typedef LocaleObjectRef LocaleNumberFormatterObjectRef;
- typedef OptionBits NumberFormatterOptionBits;
- typedef UInt32 NumberFormatterTokenID;
- struct FIndexVector {
- TextObjectIndex startIndex;
- TextObjectIndex endIndex;
- };
- typedef struct FIndexVector FIndexVector;
-
- /* index by [fPositive..fZero] */
- typedef FIndexVector TripleIndex[3];
- #define kNumberFormattingLocaleKeyName "\pnumberformattable"
-
- enum {
- /*NumberFormatterOptionBits*/
- kDontUseThousandSeparatorBit = 0,
- kIsScientificFormatBit = 1,
- kIsPercentageFormatBit = 2,
- kIsCurrencyFormatBit = 3,
- kIsFractionCurrencyFormatBit = 4,
- kIsLongFormCurrencyFormatBit = 5,
- kOmitDecimalPointInCurrencyFormatBit = 6,
- kUseAsciiDigitBit = 7,
- kUseNegativePosfixPrefixBit = 8
- };
-
-
- enum {
- /*NumberFormatterOptionBits*/
- kStandardFormatMask = 0,
- kDontUseThousandSeparatorMask = 1L << kDontUseThousandSeparatorBit,
- kIsScientificFormatMask = 1L << kIsScientificFormatBit,
- kIsPercentageFormatMask = 1L << kIsPercentageFormatBit,
- kIsCurrencyFormatMask = 1L << kIsCurrencyFormatBit,
- kIsFractionCurrencyFormatMask = 1L << kIsFractionCurrencyFormatBit,
- kIsLongFormCurrencyFormatMask = 1L << kIsLongFormCurrencyFormatBit,
- kOmitDecimalPointInCurrencyFormatMask = 1L << kOmitDecimalPointInCurrencyFormatBit,
- kUseAsciiDigitMask = 1L << kUseAsciiDigitBit,
- kUseNegativePosfixPrefixMask = 1L << kUseNegativePosfixPrefixBit
- };
-
- extern OSStatus GetNumberFormatterObjectFromRef(LocaleRef locale, LocaleNumberFormatterObjectRef *numberFormatterObject);
-
- extern OSStatus GetNumberFormatterObjectFromID(LocaleIdentifier localeID, LocaleNumberFormatterObjectRef *numberFormatterObject);
-
- extern OSStatus GetCurrentNumberFormatterObject(LocaleNumberFormatterObjectRef *numberFormatterObject);
-
- extern OSStatus GetNumberFormatterObjectInfo(LocaleNumberFormatterObjectRef numberFormatterObject, TextEncoding *theEncoding, LocaleIdentifier *theLocaleIdentifier);
-
- extern OSStatus ConvertUInt32ToTextObject(UInt32 theUInt32, LocaleNumberFormatterObjectRef numberFormatterObject, NumberFormatterOptionBits options, TextObject theTextObject, TextObjectIndex startReplaceIndex, TextObjectIndex endReplaceIndex);
-
- extern OSStatus ConvertSInt32ToTextObject(SInt32 theSInt32, LocaleNumberFormatterObjectRef numberFormatterObject, NumberFormatterOptionBits options, TextObject theTextObject, TextObjectIndex startReplaceIndex, TextObjectIndex endReplaceIndex);
-
- extern OSStatus ConvertUInt64ToTextObject(UInt64 theUInt64, LocaleNumberFormatterObjectRef numberFormatterObject, NumberFormatterOptionBits options, TextObject theTextObject, TextObjectIndex startReplaceIndex, TextObjectIndex endReplaceIndex);
-
- extern OSStatus ConvertSInt64ToTextObject(SInt64 theSInt64, LocaleNumberFormatterObjectRef numberFormatterObject, NumberFormatterOptionBits options, TextObject theTextObject, TextObjectIndex startReplaceIndex, TextObjectIndex endReplaceIndex);
-
- extern OSStatus ConvertDoubleToTextObject(double theDouble, LocaleNumberFormatterObjectRef numberFormatterObject, NumberFormatterOptionBits options, SInt8 precision, TextObject theTextObj, TextObjectIndex startReplaceIndex, TextObjectIndex endReplaceIndex);
-
- extern OSStatus ConvertTextObjectToUInt32(ConstTextObject textObject, LocaleNumberFormatterObjectRef numberFormatterObject, NumberFormatterOptionBits options, TextObjectIndex startIndex, TextObjectIndex endIndex, UInt32 *theUInt32);
-
- extern OSStatus ConvertTextObjectToSInt32(ConstTextObject textObject, LocaleNumberFormatterObjectRef numberFormatterObject, NumberFormatterOptionBits options, TextObjectIndex startIndex, TextObjectIndex endIndex, SInt32 *theSInt32);
-
- extern OSStatus ConvertTextObjectToUInt64(ConstTextObject textObject, LocaleNumberFormatterObjectRef numberFormatterObject, NumberFormatterOptionBits options, TextObjectIndex startIndex, TextObjectIndex endIndex, UInt64 *theUInt64);
-
- extern OSStatus ConvertTextObjectToSInt64(ConstTextObject textObject, LocaleNumberFormatterObjectRef numberFormatterObject, NumberFormatterOptionBits options, TextObjectIndex startIndex, TextObjectIndex endIndex, SInt64 *theSInt64);
-
- extern OSStatus ConvertTextObjectToDouble(ConstTextObject textObject, LocaleNumberFormatterObjectRef localeObjectRef, TextObjectIndex startIndex, TextObjectIndex endIndex, double *theDouble);
-
- extern OSStatus FormattedTextObjectToDouble(ConstTextObject textObject, LocaleNumberFormatterObjectRef ref, TextObjectIndex startIndex, TextObjectIndex endIndex, const NumFormatString *myCanonical, const double *num);
-
- extern OSStatus DoubleToFormattedTextObject(double *num, LocaleNumberFormatterObjectRef ref, const NumFormatString *myCanonical, TextObject outTextObject);
-
- extern OSStatus TextObjectToFormatRec(ConstTextObject textObject, LocaleNumberFormatterObjectRef ref, TextObjectIndex startIndex, TextObjectIndex endIndex, NumFormatString *outString);
-
- extern OSStatus FormatRecToTextObject(const NumFormatString *myCanonical, LocaleNumberFormatterObjectRef ref, TextObject outTextObject, TripleIndex positions);
-
-
- enum {
- /* NumberFormatterTokenID*/
- kNumFmtCharLeftQuote = 0, /*(begin literal)*/
- kNumFmtCharRightQuote = 1, /*(end literal)*/
- kNumFmtCharLeadPlacer = 2, /* (‘^’ in U.S)*/
- kNumFmtCharLeader = 3, /*(non-breakable space in U.S)*/
- kNumFmtCharNonLeader = 4, /*(# sign in U.S)*/
- kNumFmtCharZeroLead = 5, /*(digit ‘0’ in U.S)*/
- kNumFmtCharCurrencyPlacer = 6, /* (‘$’ in U.S)*/
- kNumFmtCharPercent = 7, /* (‘%’) */
- kNumFmtCharPlusSign = 8, /* (‘+’)*/
- kNumFmtCharMinusSign = 9, /* (‘-’) */
- kNumFmtCharThousandSep = 10, /* (‘,’) */
- kNumFmtCharFormatSeparator = 11, /* (‘;’) */
- kNumFmtCharEscape = 12, /* (‘\’) */
- kNumFmtCharDecPoint = 13, /* (‘.’) */
- kNumFmtTextpePlus = 14, /* (‘E+’) */
- kNumFmtTextpeMinus = 15, /* (‘E-’) */
- kNumFmtTextMinusPlus = 16, /* (‘E’) */
- kNumFmtTextFirstRangeCurrencyForm = 17, /* (‘Dollar’) */
- kNumFmtTextSecondRangeCurrencyForm = 18, /* (‘Dollar(s)’) */
- kNumFmtTextPluralCurrency = 19, /* (‘Dollar(s)’) */
- kNumFmtTextfractionCurrency = 20, /* (‘cents)) */
- kNumFmtTextCurrencyAbbreviated = 21, /* (‘$’) */
- kNumFmtTextfractionCurrencyAbbreviated = 22, /* (‘¢’) */
- kNumFmtTextNegativePrefix = 23, /* (‘(‘) */
- kNumFmtTextNegativePostfix = 24 /* (‘)’) */
- };
-
- typedef UInt32 CurrencyPosition;
-
- enum {
- /*CurrencyPosition*/
- kAtTheBeginning = 0,
- kAtDecimalPointPosition = 1,
- kAtTheEnd = 2
- };
-
- extern OSStatus CreateCustomNumberFormatLocaleObject(LocaleNumberFormatterObjectRef numberFormatterObject, LocaleNumberFormatterObjectRef *customNumberFormatterObject);
-
- extern OSStatus DeleteCustomNumberFormatLocaleObject(LocaleNumberFormatterObjectRef customNumberFormatterObject);
-
- extern OSStatus SetNumFmtTokenToParserToken(LocaleNumberFormatterObjectRef customNumberFormatterObject, NumberFormatterTokenID tokenID, BasicToken theToken);
-
- extern OSStatus GetParserTokenFromNumFmtToken(LocaleNumberFormatterObjectRef customNumberFormatterObject, NumberFormatterTokenID tokenID, BasicToken *theToken);
-
- extern OSStatus GetNumberFormatterTextFromToken(LocaleNumberFormatterObjectRef customNumberFormatterObject, NumberFormatterTokenID tokenID, TextObject theTextObject);
-
- extern OSStatus SetNumFmtTokenToText(LocaleNumberFormatterObjectRef customNumberFormatterObject, NumberFormatterTokenID tokenID, ConstTextObject theTextObject);
-
- extern OSStatus GetLocaleLongCurrencyPosition(LocaleNumberFormatterObjectRef customNumberFormatterObject, CurrencyPosition *position);
-
- extern OSStatus SetLocaleLongCurrencyPosition(LocaleNumberFormatterObjectRef customNumberFormatterObject, CurrencyPosition position);
-
- extern OSStatus GetLocaleAbbrevCurrencyPosition(LocaleNumberFormatterObjectRef customNumberFormatterObject, CurrencyPosition *position);
-
- extern OSStatus SetLocaleAbbrevCurrencyPosition(LocaleNumberFormatterObjectRef customNumberFormatterObject, CurrencyPosition position);
-
- extern OSStatus GetLocaleFirstRangeCurrency(LocaleNumberFormatterObjectRef customNumberFormatterObject, UInt32 *maxValueInRange);
-
- extern OSStatus SetLocaleFirstRangeCurrency(LocaleNumberFormatterObjectRef customNumberFormatterObject, UInt32 maxValueInRange);
-
- extern OSStatus GetLocaleSecondRangeCurrency(LocaleNumberFormatterObjectRef customNumberFormatterObject, UInt32 *maxValueInRange);
-
- extern OSStatus SetLocaleSecondRangeCurrency(LocaleNumberFormatterObjectRef customNumberFormatterObject, UInt32 maxValueInRange);
-
- extern OSStatus GetLocaleDigitText(LocaleNumberFormatterObjectRef customNumberFormatterObject, UInt8 theDigit, TextObject theTextObject);
-
- extern OSStatus SetLocaleDigitText(LocaleNumberFormatterObjectRef customNumberFormatterObject, UInt8 theDigit, TextObject theTextObject);
-
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import off
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __NUMBERFORMATTING__ */
-
-